﻿Imports VN.INS.DL.DH
Imports VN.INS.BL.BE
Public Class ReprogramarPoaDA
    Public Function Lista_Monitoreador(ByVal strCodPPER As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String

        Try

            lxc_SQL = "SELECT per.PERSONA, per.NOMBRES || ' ' || per.APELLIDO_PATERNO AS NOMBRES " & _
                        "FROM persona per INNER JOIN usuario U ON per.USUARIO = U.USUARIO  " & _
                        "WHERE U.perfil='MO' AND " & _
                                   "Per.Pper = '" & strCodPPER & "' " & _
                        "ORDER BY per.NOMBRES"

            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt

        Catch ex As Exception
            Throw
        End Try
    End Function
    Public Function Lista_Unidades() As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String

        Try

            lxc_SQL = " SELECT Unidad,descripcion FROM unidad ORDER BY descripcion "

            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt

        Catch ex As Exception
            Throw
        End Try
    End Function
    Public Function lista_ejecutor() As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String

        Try

            lxc_SQL = " select ejecutor,descripcion from ejecutor "

            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt

        Catch ex As Exception
            Throw
        End Try
    End Function
    Public Function lista_ambito() As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String

        Try

            lxc_SQL = " SELECT  CODIGO,DESCRIPCION FROM general WHERE id='AMBITO' "

            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt

        Catch ex As Exception
            Throw
        End Try
    End Function
    Public Function lista_especialista() As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String

        Try

            lxc_SQL = " select per.PERSONA, per.NOMBRES || ' ' || per.APELLIDO_PATERNO AS NOMBRES from persona per inner join usuario u on per.USUARIO = u.USUARIO   where u.perfil='EP' ORDER BY per.NOMBRES"

            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt

        Catch ex As Exception
            Throw
        End Try
    End Function
    Public Function lista_departamento() As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = " select ubigeo,nombre,departamento from ubigeo ub where ub.PROVINCIA='00' and ub.DISTRITO='00'"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt
        Catch ex As Exception
            Throw
        End Try
    End Function
    Public Function lista_provincia(ByVal DP As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = " select ubigeo,nombre,provincia from ubigeo ub where  ub.DISTRITO='00' and ub.DEPARTAMENTO='" + DP + "'"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt
        Catch ex As Exception
            Throw
        End Try
    End Function
    Public Function tipo_cambio() As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = " select CODIGO,DESCRIPCION from GENERAL WHERE ID='TIPO_CAMBIO' "
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt
        Catch ex As Exception
            Throw
        End Try
    End Function
    Public Function lista_distrito(ByVal prv As String, ByVal DP As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = " select ubigeo,nombre from ubigeo ub where ub.PROVINCIA='" + prv + "' and ub.DEPARTAMENTO='" + DP + "'"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt
        Catch ex As Exception
            Throw
        End Try
    End Function
    Public Function lista_producto(ByVal ppr As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = "SELECT producto,descripcion FROM PRODUCTO where pper='" + ppr + "'"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt
        Catch ex As Exception
            Throw
        End Try
    End Function
    Public Function cargarGrilla() As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = "SELECT P.NOMBRE, P.MONTO_TOTAL_INVERTIDO, P.MONTO_INV_ANHIO, P.NUM_BENEFICIARIOS_DIRECTOS,PM.NOMBRES || ' ' || PM.APELLIDO_PATERNO || ' ' || PM.APELLIDO_MATERNO AS MONITOREADOR, " & _
                      "PE.NOMBRES || ' ' || PE.APELLIDO_PATERNO || ' ' || PE.APELLIDO_MATERNO AS ESPECIALISTA, P.OBJETIVO,P.SNIP,P.FECHA_VIABILIDAD, P.POA ,U.NOMBRE AS UBIGEO, TPA.DESCRIPCION,PP. ABREVIATURA FROM POA P " & _
                      "INNER JOIN TIPO_PROYECTO_ACTIVIDAD TPA ON TPA.TIPO_PROYECTO_ACTIVIDAD = P.TIPO_PROYECTO_ACTIVIDAD INNER JOIN PPER PP ON PP.PPER = P.PPER " & _
                      "LEFT JOIN PERSONA PM ON PM.PERSONA = P.PERSONA_MONITOREO " & _
                      "LEFT JOIN PERSONA PE ON PE.PERSONA = P.PERSONA_ESPECIALISTA " & _
                      "LEFT JOIN UBIGEO  U ON U.UBIGEO = P.UBIGEO "
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt
        Catch ex As Exception
            Throw ex
        End Try
    End Function
    Public Sub editar_poa_principal(ByVal tipCamb As String, ByVal ejec As String, ByVal doc As String, ByVal VERS As Integer, ByVal POA1 As String, ByVal nomb As String, ByVal obj As String, ByVal mt1 As String, ByVal umt1 As String,
                      ByVal mt2 As String, ByVal umt2 As String, ByVal mt3 As String, ByVal umt3 As String,
                      ByVal monto As Decimal, ByVal montoaño As Decimal, ByVal añofirm As String, ByVal monitoreador As String,
                      ByVal espec As String, ByVal mesfirm As String, ByVal dpto As String, ByVal tipodoc As String,
                      ByVal snip As String, ByVal fviabilidad As String, ByVal convenio As String, ByVal ambit As String,
                      ByVal estado As String, ByVal pper As String, ByVal produc As String, ByVal MontTrans As Decimal, ByRef TipoAsig As String, ByVal TipoProyDes As String)
        Dim objData As AdministradorOracle = New AdministradorOracle
        Try

            objData.CreateInputOracle("POAX", POA1, 20)
            objData.CreateInputOracle("NOM", nomb, 500)
            objData.CreateInputOracle("UBIG", dpto, 20)
            objData.CreateInputOracle("OBJ", obj, 1000)
            objData.CreateInputOracle("SNIPX", snip, 20)
            objData.CreateInputOracle("TipProAct", tipodoc, 20)
            objData.CreateInputOracle("FecViab", fviabilidad, 20)
            objData.CreateInputOracle("Conv", convenio, 20)
            objData.CreateInputOracle("Produc", produc, 20)
            objData.CreateInputOracle("Estd", estado, 20)
            objData.CreateInputOracle("PPERX", pper, 20)
            objData.CreateInputOracle("Ambit", ambit, 20)
            objData.CreateInputOracle("Ejec", ejec, 20)
            objData.CreateInputOracle("MontoInvTot", monto, 20)
            objData.CreateInputOracle("MontoInvAn", montoaño, 20)
            objData.CreateInputOracle("Monit", monitoreador, 20)
            objData.CreateInputOracle("Espec", espec, 20)
            objData.CreateInputOracle("AnFirma", añofirm, 20)
            objData.CreateInputOracle("MesFirma", mesfirm, 20)
            objData.CreateInputOracle("MET1", mt1, 20)
            objData.CreateInputOracle("UND1", umt1, 20)
            objData.CreateInputOracle("MET2", mt2, 20)
            objData.CreateInputOracle("UND2", umt2, 20)
            objData.CreateInputOracle("MET3", mt3, 20)
            objData.CreateInputOracle("UND3", umt3, 20)
            objData.CreateInputOracle("DOC", doc, 20)
            objData.CreateInputOracle("MontTrans", MontTrans, 20)
            objData.CreateInputOracle("TipoAsig", TipoAsig, 2)
            objData.CreateInputOracle("TipoProyDes", TipoProyDes, 2)
            objData.ExecuteOracle_NonQuery("Procedur_Reprogramar", "Conexion.Oracle")

        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public Sub editar_poa_componente(ByVal poa As String, ByVal comp As String, ByVal Descripcion As String, ByVal version As String, ByVal compoh As String, ByVal acom As String, ByVal pesocomp As Integer)
        Dim objData As AdministradorOracle = New AdministradorOracle
        Try
            objData.CreateInputOracle("POAX", poa, 8)
            objData.CreateInputOracle("COMPOX", comp, 8)
            objData.CreateInputOracle("DESCRIPX", Descripcion, 1000)
            objData.CreateInputOracle("VERSX", version, 5)
            objData.CreateInputOracle("compohX", compoh, 5)
            objData.CreateInputOracle("PESOCOMP", pesocomp, 5)         
            objData.ExecuteOracle_NonQuery("EDITAR_REPROGRAMAR_COMPONENTE", "Conexion.Oracle")
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public Sub editar_poa_componente_ht(ByVal poa As String, ByVal comp As String, ByVal Descripcion As String, ByVal version As String, ByVal compoh As String)
        Dim objData As AdministradorOracle = New AdministradorOracle
        Try

            objData.CreateInputOracle("COMPOX", comp, 8)
            objData.CreateInputOracle("POAX", poa, 8)
            objData.CreateInputOracle("DESCRIPX", Descripcion, 1000)
            objData.CreateInputOracle("VERSX", version, 5)
            objData.CreateInputOracle("compohX", Convert.ToInt16(compoh), 5)

            objData.ExecuteOracle_NonQuery("BORRADOR_REPRO_COMPONENTE", "Conexion.Oracle")
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public Sub editar_poa_financiero(ByVal GENE As String, ByVal ESPEC As String, ByVal version As Integer, ByVal IDPFN As String,
                                         ByVal MT1 As String, ByVal MT2 As String, ByVal MT3 As String, ByVal MT4 As String, ByVal MT5 As String, ByVal MT6 As String,
                                         ByVal MT7 As String, ByVal MT8 As String, ByVal MT9 As String, ByVal MT10 As String, ByVal MT11 As String, ByVal MT12 As String,
                                         ByVal MTAF As String, ByVal POAX As String, ByVal IDFNH As String)
        Dim objData As AdministradorOracle = New AdministradorOracle
        Try

            objData.CreateInputOracle("GENE", GENE, 20)
            objData.CreateInputOracle("ESPEC", ESPEC, 20)
            objData.CreateInputOracle("VERS", version, 20)
            objData.CreateInputOracle("IDPFN", IDPFN, 20)
            objData.CreateInputOracle("MT1", MT1, 20)
            objData.CreateInputOracle("MT2", MT2, 20)
            objData.CreateInputOracle("MT3", MT3, 20)
            objData.CreateInputOracle("MT4", MT4, 20)
            objData.CreateInputOracle("MT5", MT5, 20)
            objData.CreateInputOracle("MT6", MT6, 20)
            objData.CreateInputOracle("MT7", MT7, 20)
            objData.CreateInputOracle("MT8", MT8, 20)
            objData.CreateInputOracle("MT9", MT9, 20)
            objData.CreateInputOracle("MT10", MT10, 20)
            objData.CreateInputOracle("MT11", MT11, 20)
            objData.CreateInputOracle("MT12", MT12, 20)
            objData.CreateInputOracle("MTAF", MTAF, 20)
            objData.CreateInputOracle("POAX", POAX, 20)
            objData.CreateInputOracle("IDFNH", IDFNH, 20)

            objData.ExecuteOracle_NonQuery("EDITAR_POA_ACT_FINANCIERO", "Conexion.Oracle")
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public Sub editar_poa_fisico(ByVal comp As String, ByVal Descripcion As String, ByVal version As String, ByVal unidad As String, ByVal IDPF As String,
                                        ByVal MT1 As String, ByVal MT2 As String, ByVal MT3 As String, ByVal MT4 As String, ByVal MT5 As String, ByVal MT6 As String,
                                        ByVal MT7 As String, ByVal MT8 As String, ByVal MT9 As String, ByVal MT10 As String, ByVal MT11 As String, ByVal MT12 As String,
                                        ByVal MTA As String, ByVal PESOX As String, ByVal POAX As String, ByVal IDFH As String, ByVal IDPC As String, ByVal COD As String)
        Dim objData As AdministradorOracle = New AdministradorOracle
        Try
            objData.CreateInputOracle("COMP", comp, 200)
            objData.CreateInputOracle("TDESC", Descripcion, 200)
            objData.CreateInputOracle("VERS", version, 20)
            objData.CreateInputOracle("UND", unidad, 20)
            objData.CreateInputOracle("IDPF", IDPF, 20)
            objData.CreateInputOracle("PESOX", PESOX, 20)
            objData.CreateInputOracle("MT1", MT1, 20)
            objData.CreateInputOracle("MT2", MT2, 20)
            objData.CreateInputOracle("MT3", MT3, 20)
            objData.CreateInputOracle("MT4", MT4, 20)
            objData.CreateInputOracle("MT5", MT5, 20)
            objData.CreateInputOracle("MT6", MT6, 20)
            objData.CreateInputOracle("MT7", MT7, 20)
            objData.CreateInputOracle("MT8", MT8, 20)
            objData.CreateInputOracle("MT9", MT9, 20)
            objData.CreateInputOracle("MT10", MT10, 20)
            objData.CreateInputOracle("MT11", MT11, 20)
            objData.CreateInputOracle("MT12", MT12, 20)
            objData.CreateInputOracle("MTA", MTA, 20)
            objData.CreateInputOracle("POAX", POAX, 8)
            objData.CreateInputOracle("IDFH", IDFH, 20)
            objData.CreateInputOracle("IDPC", IDPC, 20)
            objData.CreateInputOracle("COD", COD, 10)            
            objData.ExecuteOracle_NonQuery("EDITAR_POA_ACT_FISICO", "Conexion.Oracle")
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public Sub insertar_poa(ByVal tipCamb As String, ByVal ejec As String, ByVal doc As String, ByVal VERS As Integer, ByVal POA1 As String, ByVal nomb As String, ByVal obj As String, ByVal mt1 As String, ByVal umt1 As String,
                          ByVal mt2 As String, ByVal umt2 As String, ByVal mt3 As String, ByVal umt3 As String,
                          ByVal monto As Decimal, ByVal montoaño As Decimal, ByVal añofirm As String, ByVal monitoreador As String,
                          ByVal espec As String, ByVal mesfirm As String, ByVal dpto As String, ByVal tipodoc As String,
                          ByVal snip As String, ByVal fviabilidad As String, ByVal convenio As String, ByVal ambit As String,
                          ByVal estado As String, ByVal pper As String, ByVal produc As String, ByVal VER As String, ByVal MontTrans As Decimal, ByRef TipoAsig As String, ByVal TipoProyDes As String, ByVal COOX As String, ByVal COOY As String, ByVal OBS As String)
        Dim objData As AdministradorOracle = New AdministradorOracle
        Try
            objData.CreateInputOracle("POAX", POA1, 20)
            objData.CreateInputOracle("NOM", nomb, 500)
            objData.CreateInputOracle("UBIG", dpto, 20)
            objData.CreateInputOracle("OBJ", obj, 1000)
            objData.CreateInputOracle("SNIPX", snip, 20)
            objData.CreateInputOracle("TipProAct", tipodoc, 20)
            objData.CreateInputOracle("FecViab", fviabilidad, 20)
            objData.CreateInputOracle("Conv", convenio, 20)
            objData.CreateInputOracle("Produc", produc, 20)
            objData.CreateInputOracle("Estd", estado, 20)
            objData.CreateInputOracle("PPERX", pper, 20)
            objData.CreateInputOracle("Ambit", ambit, 20)
            objData.CreateInputOracle("Ejec", ejec, 20)
            objData.CreateInputOracle("MontoInvTot", monto, 20)
            objData.CreateInputOracle("MontoInvAn", montoaño, 20)
            objData.CreateInputOracle("Monit", monitoreador, 20)
            objData.CreateInputOracle("Espec", espec, 20)
            objData.CreateInputOracle("AnFirma", añofirm, 20)
            objData.CreateInputOracle("MesFirma", mesfirm, 20)
            objData.CreateInputOracle("TipCamb", tipCamb, 20)
            objData.CreateInputOracle("MET1", mt1, 20)
            objData.CreateInputOracle("UND1", umt1, 20)
            objData.CreateInputOracle("MET2", mt2, 20)
            objData.CreateInputOracle("UND2", umt2, 20)
            objData.CreateInputOracle("MET3", mt3, 20)
            objData.CreateInputOracle("UND3", umt3, 20)
            objData.CreateInputOracle("VERS", VERS, 20)
            objData.CreateInputOracle("DOC", doc, 20)
            objData.CreateInputOracle("MontTrans", MontTrans, 20)
            objData.CreateInputOracle("TipoAsig", TipoAsig, 2)
            objData.CreateInputOracle("TipoProyDes", TipoProyDes, 2)
            objData.CreateInputOracle("COOX", COOX, 20)
            objData.CreateInputOracle("COOY", COOY, 20)
            objData.CreateInputOracle("OBS", OBS, 500)
            objData.ExecuteOracle_NonQuery("Procedur_Reprogramar", "Conexion.Oracle")
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public Sub insertar_poa_ht(ByVal tipCamb As String, ByVal ejec As String, ByVal doc As String, ByVal VERS As Integer, ByVal POA1 As String, ByVal nomb As String, ByVal obj As String, ByVal mt1 As String, ByVal umt1 As String,
                          ByVal mt2 As String, ByVal umt2 As String, ByVal mt3 As String, ByVal umt3 As String,
                          ByVal monto As String, ByVal montoaño As String, ByVal añofirm As String, ByVal monitoreador As String,
                          ByVal espec As String, ByVal mesfirm As String, ByVal dpto As String, ByVal tipodoc As String,
                          ByVal snip As String, ByVal fviabilidad As String, ByVal convenio As String, ByVal ambit As String,
                          ByVal estado As String, ByVal pper As String, ByVal produc As String, ByVal MontTrans As Decimal, ByRef TipoAsig As String, ByVal TipoProyDes As String)
        Dim objData As AdministradorOracle = New AdministradorOracle
        Try
            objData.CreateInputOracle("POAX", POA1, 20)
            objData.CreateInputOracle("NOM", nomb, 500)
            objData.CreateInputOracle("UBIG", dpto, 20)
            objData.CreateInputOracle("OBJ", obj, 1000)
            objData.CreateInputOracle("SNIPX", snip, 20)
            objData.CreateInputOracle("TipProAct", tipodoc, 20)
            objData.CreateInputOracle("FecViab", fviabilidad, 20)
            objData.CreateInputOracle("Conv", convenio, 20)
            objData.CreateInputOracle("Produc", produc, 20)
            objData.CreateInputOracle("Estd", estado, 20)
            objData.CreateInputOracle("PPERX", pper, 20)
            objData.CreateInputOracle("Ambit", ambit, 20)
            objData.CreateInputOracle("Ejec", ejec, 20)
            objData.CreateInputOracle("MontoInvTot", monto, 20)
            objData.CreateInputOracle("MontoInvAn", montoaño, 20)
            objData.CreateInputOracle("Monit", monitoreador, 20)
            objData.CreateInputOracle("Espec", espec, 20)
            objData.CreateInputOracle("AnFirma", añofirm, 20)
            objData.CreateInputOracle("MesFirma", mesfirm, 20)
            objData.CreateInputOracle("TipCamb", tipCamb, 20)
            objData.CreateInputOracle("MET1", mt1, 20)
            objData.CreateInputOracle("UND1", umt1, 20)
            objData.CreateInputOracle("MET2", mt2, 20)
            objData.CreateInputOracle("UND2", umt2, 20)
            objData.CreateInputOracle("MET3", mt3, 20)
            objData.CreateInputOracle("UND3", umt3, 20)
            objData.CreateInputOracle("VERS", VERS, 20)
            objData.CreateInputOracle("DOC", doc, 20)
            objData.CreateInputOracle("MontTrans", MontTrans, 20)
            objData.CreateInputOracle("TipoAsig", TipoAsig, 2)
            objData.CreateInputOracle("TipoProyDes", TipoProyDes, 2)
            objData.ExecuteOracle_NonQuery("Procedur_Reprogramar_borrador", "Conexion.Oracle")
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public Sub insertar_componente(ByVal poa As String, ByVal comp As String, ByVal Descripcion As String, ByVal version As String, ByVal comph As Integer, ByVal pesocom As Integer)
        Dim objData As AdministradorOracle = New AdministradorOracle
        Try
            objData.CreateInputOracle("POAX", poa, 20)
            objData.CreateInputOracle("compo", comp, 20)
            objData.CreateInputOracle("descrip", Descripcion, 1000)
            objData.CreateInputOracle("VERS", version, 20)
            objData.CreateInputOracle("compoh", comph, 20)
            objData.CreateInputOracle("PESOCOMP", pesocom, 20)
            objData.ExecuteOracle_NonQuery("insert_componente", "Conexion.Oracle")
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public Sub delete_update_finan(ByVal poa As String, ByVal idfin As Integer, ByVal ver As String)
        Dim objData As AdministradorOracle = New AdministradorOracle
        Try
            objData.CreateInputOracle("POAFIN", poa, 8)
            objData.CreateInputOracle("IDPAFN", idfin, 10)
            objData.CreateInputOracle("VER", ver, 2)
            objData.ExecuteOracle_NonQuery("delete_update_fin", "Conexion.Oracle")

        Catch ex As Exception
            Throw
        End Try
    End Sub
    Public Sub delete_update_fis(ByVal poa As String, ByVal idfis As Integer, ByVal ver As String)
        Dim objData As AdministradorOracle = New AdministradorOracle
        Try
            objData.CreateInputOracle("POAFIS", poa, 8)
            objData.CreateInputOracle("IDPAFS", Convert.ToInt16(idfis), 10)
            objData.CreateInputOracle("VER", ver, 2)
            objData.ExecuteOracle_NonQuery("delete_update_fis", "Conexion.Oracle")

        Catch ex As Exception
            Throw
        End Try


    End Sub
    Public Sub delete_update_comp(ByVal poa As String, ByVal COMP As Integer, ByVal ver As String)
        Dim objData As AdministradorOracle = New AdministradorOracle
        Try
            objData.CreateInputOracle("POACOMP", poa, 8)
            objData.CreateInputOracle("COMP", COMP, 10)
            objData.CreateInputOracle("VER", ver, 2)
            objData.ExecuteOracle_NonQuery("delete_update_comp", "Conexion.Oracle")
        Catch ex As Exception
            Throw
        End Try
    End Sub
    Public Sub insertar_actividad_fisica(ByVal poa As String, ByVal comp As String, ByVal Descripcion As String, ByVal version As String, ByVal unidad As String, ByVal IDPF As String,
                                        ByVal MT1 As String, ByVal MT2 As String, ByVal MT3 As String, ByVal MT4 As String, ByVal MT5 As String, ByVal MT6 As String,
                                        ByVal MT7 As String, ByVal MT8 As String, ByVal MT9 As String, ByVal MT10 As String, ByVal MT11 As String, ByVal MT12 As String,
                                        ByVal MTA As Integer, ByVal IDFH As Integer, ByVal IDPC As Integer, ByVal verfis As String, ByVal PESO As Integer, ByVal COD As String)
        Dim objData As AdministradorOracle = New AdministradorOracle
        Try
            objData.CreateInputOracle("POAX", poa, 20)
            objData.CreateInputOracle("COMP", comp, 200)
            objData.CreateInputOracle("TDESC", Descripcion, 200)
            objData.CreateInputOracle("VERS", version, 20)
            objData.CreateInputOracle("UND", unidad, 20)
            objData.CreateInputOracle("IDPF", IDPF, 20)
            objData.CreateInputOracle("MT1", MT1, 20)
            objData.CreateInputOracle("MT2", MT2, 20)
            objData.CreateInputOracle("MT3", MT3, 20)
            objData.CreateInputOracle("MT4", MT4, 20)
            objData.CreateInputOracle("MT5", MT5, 20)
            objData.CreateInputOracle("MT6", MT6, 20)
            objData.CreateInputOracle("MT7", MT7, 20)
            objData.CreateInputOracle("MT8", MT8, 20)
            objData.CreateInputOracle("MT9", MT9, 20)
            objData.CreateInputOracle("MT10", MT10, 20)
            objData.CreateInputOracle("MT11", MT11, 20)
            objData.CreateInputOracle("MT12", MT12, 20)
            objData.CreateInputOracle("MTA", MTA, 20)
            objData.CreateInputOracle("IDFH", IDFH, 20)
            objData.CreateInputOracle("IDPC", IDPC, 20)
            objData.CreateInputOracle("PESOX", PESO, 20)
            objData.CreateInputOracle("COD", COD, 10)
            objData.ExecuteOracle_NonQuery("insert_actividad_fisica", "Conexion.Oracle")
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public Sub insertar_actividad_fisicHT(ByVal poa As String, ByVal comp As String, ByVal Descripcion As String, ByVal version As String, ByVal unidad As String, ByVal IDPF As String,
                                       ByVal MT1 As String, ByVal MT2 As String, ByVal MT3 As String, ByVal MT4 As String, ByVal MT5 As String, ByVal MT6 As String,
                                       ByVal MT7 As String, ByVal MT8 As String, ByVal MT9 As String, ByVal MT10 As String, ByVal MT11 As String, ByVal MT12 As String,
                                       ByVal MTA As String, ByVal IDFH As Integer, ByVal IDPC As Integer, ByVal Afis As String, ByVal PESO As Integer)
        Dim objData As AdministradorOracle = New AdministradorOracle
        Try

            objData.CreateInputOracle("POAX", poa, 20)
            objData.CreateInputOracle("COMP", comp, 200)
            objData.CreateInputOracle("TDESC", Descripcion, 200)
            objData.CreateInputOracle("VERS", version, 20)
            objData.CreateInputOracle("UND", unidad, 20)
            objData.CreateInputOracle("IDPF", IDPF, 20)
            objData.CreateInputOracle("MT1", MT1, 20)
            objData.CreateInputOracle("MT2", MT2, 20)
            objData.CreateInputOracle("MT3", MT3, 20)
            objData.CreateInputOracle("MT4", MT4, 20)
            objData.CreateInputOracle("MT5", MT5, 20)
            objData.CreateInputOracle("MT6", MT6, 20)
            objData.CreateInputOracle("MT7", MT7, 20)
            objData.CreateInputOracle("MT8", MT8, 20)
            objData.CreateInputOracle("MT9", MT9, 20)
            objData.CreateInputOracle("MT10", MT10, 20)
            objData.CreateInputOracle("MT11", MT11, 20)
            objData.CreateInputOracle("MT12", MT12, 20)
            objData.CreateInputOracle("MTA", MTA, 20)
            objData.CreateInputOracle("IDFH", IDFH, 20)
            objData.CreateInputOracle("IDPC", IDPC, 20)
            objData.CreateInputOracle("PESOX", PESO, 20)
            If Afis = "1" Then
                objData.ExecuteOracle_NonQuery("EDITAR_REPROGRAMAR_FISICO", "Conexion.Oracle")
            ElseIf Afis = "2" Then
                objData.ExecuteOracle_NonQuery("update_borrador_fisica", "Conexion.Oracle")
            ElseIf Afis = "3" Then
                objData.ExecuteOracle_NonQuery("insert_borrador_fisica", "Conexion.Oracle")
            End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public Sub insertar_actividad_fisicHT_BR(ByVal poa As String, ByVal comp As String, ByVal Descripcion As String, ByVal version As String, ByVal unidad As String, ByVal IDPF As String,
                                   ByVal MT1 As String, ByVal MT2 As String, ByVal MT3 As String, ByVal MT4 As String, ByVal MT5 As String, ByVal MT6 As String,
                                   ByVal MT7 As String, ByVal MT8 As String, ByVal MT9 As String, ByVal MT10 As String, ByVal MT11 As String, ByVal MT12 As String,
                                   ByVal MTA As String, ByVal IDFH As Integer, ByVal IDPC As Integer)
        Dim objData As AdministradorOracle = New AdministradorOracle
        Try

            objData.CreateInputOracle("POAX", poa, 20)
            objData.CreateInputOracle("COMP", comp, 200)
            objData.CreateInputOracle("TDESC", Descripcion, 200)
            objData.CreateInputOracle("VERS", version, 20)
            objData.CreateInputOracle("UND", unidad, 20)
            objData.CreateInputOracle("IDPF", IDPF, 20)
            objData.CreateInputOracle("MT1", Replace(MT1, ",", ""), 20)
            objData.CreateInputOracle("MT2", Replace(MT2, ",", ""), 20)
            objData.CreateInputOracle("MT3", Replace(MT3, ",", ""), 20)
            objData.CreateInputOracle("MT4", Replace(MT4, ",", ""), 20)
            objData.CreateInputOracle("MT5", Replace(MT5, ",", ""), 20)
            objData.CreateInputOracle("MT6", Replace(MT6, ",", ""), 20)
            objData.CreateInputOracle("MT7", Replace(MT7, ",", ""), 20)
            objData.CreateInputOracle("MT8", Replace(MT8, ",", ""), 20)
            objData.CreateInputOracle("MT9", Replace(MT9, ",", ""), 20)
            objData.CreateInputOracle("MT10", Replace(MT10, ",", ""), 20)
            objData.CreateInputOracle("MT11", Replace(MT11, ",", ""), 20)
            objData.CreateInputOracle("MT12", Replace(MT12, ",", ""), 20)
            objData.CreateInputOracle("MTA", Replace(MTA, ",", ""), 20)
            objData.CreateInputOracle("IDFH", IDFH, 20)
            objData.CreateInputOracle("IDPC", IDPC, 20)


            objData.ExecuteOracle_NonQuery("BORRADOR_REPROGRAMAR_FISICO", "Conexion.Oracle")
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public Sub insertar_actividad_financiera(ByVal poa As String, ByVal GENE As String, ByVal ESPEC As String, ByVal version As String, ByVal IDPFN As String,
                                         ByVal MT1 As String, ByVal MT2 As String, ByVal MT3 As String, ByVal MT4 As String, ByVal MT5 As String, ByVal MT6 As String,
                                         ByVal MT7 As String, ByVal MT8 As String, ByVal MT9 As String, ByVal MT10 As String, ByVal MT11 As String, ByVal MT12 As String,
                                         ByVal MTAF As String, ByVal IDFNH As Integer)
        Dim objData As AdministradorOracle = New AdministradorOracle
        Try

            objData.CreateInputOracle("POAX", poa, 20)
            objData.CreateInputOracle("GENE", GENE, 20)
            objData.CreateInputOracle("ESPEC", ESPEC, 20)
            objData.CreateInputOracle("VERS", version, 20)
            objData.CreateInputOracle("IDPFN", IDPFN, 20)
            objData.CreateInputOracle("MT1", MT1, 20)
            objData.CreateInputOracle("MT2", MT2, 20)
            objData.CreateInputOracle("MT3", MT3, 20)
            objData.CreateInputOracle("MT4", MT4, 20)
            objData.CreateInputOracle("MT5", MT5, 20)
            objData.CreateInputOracle("MT6", MT6, 20)
            objData.CreateInputOracle("MT7", MT7, 20)
            objData.CreateInputOracle("MT8", MT8, 20)
            objData.CreateInputOracle("MT9", MT9, 20)
            objData.CreateInputOracle("MT10", MT10, 20)
            objData.CreateInputOracle("MT11", MT11, 20)
            objData.CreateInputOracle("MT12", MT12, 20)
            objData.CreateInputOracle("MTAF", MTAF, 20)
            objData.CreateInputOracle("IDFNH", IDFNH, 20)

            objData.ExecuteOracle_NonQuery("insert_actividad_financiera", "Conexion.Oracle")
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public Sub insertar_actividad_financieraHT(ByVal poa As String, ByVal GENE As String, ByVal ESPEC As String, ByVal version As String, ByVal IDPFN As String,
                                        ByVal MT1 As String, ByVal MT2 As String, ByVal MT3 As String, ByVal MT4 As String, ByVal MT5 As String, ByVal MT6 As String,
                                        ByVal MT7 As String, ByVal MT8 As String, ByVal MT9 As String, ByVal MT10 As String, ByVal MT11 As String, ByVal MT12 As String,
                                        ByVal MTAF As Decimal, ByVal IDFNH As String, ByVal Afin As String)
        Dim objData As AdministradorOracle = New AdministradorOracle
        Try

            objData.CreateInputOracle("POAX", poa, 20)
            objData.CreateInputOracle("GENE", GENE, 20)
            objData.CreateInputOracle("ESPEC", ESPEC, 20)
            objData.CreateInputOracle("VERS", version, 20)
            objData.CreateInputOracle("IDPFN", IDPFN, 20)
            objData.CreateInputOracle("MT1", MT1, 20)
            objData.CreateInputOracle("MT2", MT2, 20)
            objData.CreateInputOracle("MT3", MT3, 20)
            objData.CreateInputOracle("MT4", MT4, 20)
            objData.CreateInputOracle("MT5", MT5, 20)
            objData.CreateInputOracle("MT6", MT6, 20)
            objData.CreateInputOracle("MT7", MT7, 20)
            objData.CreateInputOracle("MT8", MT8, 20)
            objData.CreateInputOracle("MT9", MT9, 20)
            objData.CreateInputOracle("MT10", MT10, 20)
            objData.CreateInputOracle("MT11", MT11, 20)
            objData.CreateInputOracle("MT12", MT12, 20)
            objData.CreateInputOracle("MTAF", MTAF, 20)
            objData.CreateInputOracle("IDFNH", IDFNH, 20)
            If Afin = "1" Then
                objData.ExecuteOracle_NonQuery("EDITAR_REPROGRAMAR_FINANCIERO", "Conexion.Oracle")
            ElseIf Afin = "2" Then
                objData.ExecuteOracle_NonQuery("insert_REPRO_PRINCFINAN", "Conexion.Oracle")
            ElseIf Afin = "3" Then
                objData.ExecuteOracle_NonQuery("INSERT_PRINC_FINANCIERO", "Conexion.Oracle")

            End If

        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public Sub BORRADOR_actividad_financieraHT(ByVal poa As String, ByVal GENE As String, ByVal ESPEC As String, ByVal version As String, ByVal IDPFN As String,
                                       ByVal MT1 As String, ByVal MT2 As String, ByVal MT3 As String, ByVal MT4 As String, ByVal MT5 As String, ByVal MT6 As String,
                                       ByVal MT7 As String, ByVal MT8 As String, ByVal MT9 As String, ByVal MT10 As String, ByVal MT11 As String, ByVal MT12 As String,
                                       ByVal MTAF As Decimal, ByVal IDFNH As Integer)
        Dim objData As AdministradorOracle = New AdministradorOracle
        Try



            objData.CreateInputOracle("POAX", poa, 20)

            objData.CreateInputOracle("GENE", GENE, 20)
            objData.CreateInputOracle("ESPEC", ESPEC, 20)
            objData.CreateInputOracle("VERS", version, 20)
            objData.CreateInputOracle("IDPFN", IDPFN, 20)
            objData.CreateInputOracle("MT1", MT1, 20)
            objData.CreateInputOracle("MT2", MT2, 20)
            objData.CreateInputOracle("MT3", MT3, 20)
            objData.CreateInputOracle("MT4", MT4, 20)
            objData.CreateInputOracle("MT5", MT5, 20)
            objData.CreateInputOracle("MT6", MT6, 20)
            objData.CreateInputOracle("MT7", MT7, 20)
            objData.CreateInputOracle("MT8", MT8, 20)
            objData.CreateInputOracle("MT9", MT9, 20)
            objData.CreateInputOracle("MT10", MT10, 20)
            objData.CreateInputOracle("MT11", MT11, 20)
            objData.CreateInputOracle("MT12", MT12, 20)
            objData.CreateInputOracle("MTAF", MTAF, 20)
            objData.CreateInputOracle("IDFNH", IDFNH, 20)

            objData.ExecuteOracle_NonQuery("BORRADOR_REPROG_FINANCIERO", "Conexion.Oracle")
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public Function CargarGrillaHistory(ByVal poa As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = "select PH.poa ,PH.NOMBRE,PH.VERSION,UB.NOMBRE Ubigeo,PH.OBJETIVO,PH.SNIP,TPA.DESCRIPCION as tipo_poa, " + _
" PH.FECHA_VIABILIDAD, cn.NOMBRE CONVENIO, PD.DESCRIPCION PRODUCTO,   " + _
" GNRL2.DESCRIPCION AS ESTADO,PPER.ABREVIATURA PPER,PH.AMBITO, EJEC.DESCRIPCION EJECUTOR,   PH.MONTO_TOTAL_INVERTIDO, " + _
" PH.MONTO_INV_ANHIO,PM.NOMBRES || ' ' || PM.APELLIDO_PATERNO || ' ' || PM.APELLIDO_MATERNO AS MONITOREADOR, " + _
" PE.NOMBRES || ' ' || PE.APELLIDO_PATERNO || ' ' || PE.APELLIDO_MATERNO AS ESPECIALISTA,  " + _
"  PH.ANHIO_FIRMA_POA, PH.MES_FIRMA_POA, PH.TIPO_CAMBIO_POA,GNRL.DESCRIPCION AS TIPO_CAMBIO, PH.META, U.DESCRIPCION unidad1, " + _
" PH.META2, U2.DESCRIPCION unidad2,  PH.META3, U3.DESCRIPCION unidad3, PH.DOCUMENTO  " + _
" from POA_HISTORICO PH  " + _
" LEFT JOIN UBIGEO UB ON PH.UBIGEO=UB.UBIGEO  " + _
" LEFT JOIN TIPO_PROYECTO_ACTIVIDAD TPA ON PH.TIPO_PROYECTO_ACTIVIDAD=TPA.TIPO_PROYECTO_ACTIVIDAD " + _
" left JOIN CONVENIO   cn on cn.CONVENIO = PH.CONVENIO  " + _
" LEFT JOIN PRODUCTO PD ON PD.PRODUCTO = PH.PRODUCTO " + _
" LEFT JOIN PPER ON PH.PPER = PPER.PPER " + _
" LEFT JOIN EJECUTOR EJEC ON EJEC.EJECUTOR = PH.EJECUTOR " + _
" LEFT JOIN PERSONA PM ON PM.PERSONA = PH.PERSONA_MONITOREO " + _
" LEFT JOIN PERSONA PE ON PE.PERSONA = PH.PERSONA_ESPECIALISTA  " + _
" LEFT JOIN UNIDAD  U ON  PH.UNIDAD = U.UNIDAD " + _
" LEFT JOIN UNIDAD U2 ON PH.UNIDAD2= U2.UNIDAD " + _
" LEFT JOIN UNIDAD U3 ON PH.UNIDAD3 = U3.UNIDAD " + _
" LEFT JOIN GENERAL GNRL ON PH.TIPO_CAMBIO_POA = GNRL.CODIGO AND GNRL.ID='TIPO_CAMBIO' " + _
"LEFT JOIN GENERAL GNRL2 ON PH.ESTADO = GNRL2.CODIGO AND GNRL2.ID='ESTADO_POA' " + _
" where poa='" + poa + "'"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt
        Catch ex As Exception
            Throw ex
        End Try
    End Function
    Public Function modific_poaPrinc(ByVal poa As String, ByVal VERH As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String

        Try

            If VERH = "" Then
                lxc_SQL = " SELECT NOMBRE,UBIGEO,OBJETIVO,SNIP,TIPO_PROYECTO_ACTIVIDAD,FECHA_VIABILIDAD,CONVENIO " + _
                                  ",PRODUCTO,ESTADO ,PPER,AMBITO,EJECUTOR,MONTO_TOTAL_INVERTIDO,MONTO_INV_ANHIO,PERSONA_MONITOREO " + _
                                  " ,PERSONA_ESPECIALISTA,ANHIO_FIRMA_POA,MES_FIRMA_POA,TIPO_CAMBIO_POA,META,UNIDAD,META2,UNIDAD2 " + _
                                  " ,META3,UNIDAD3,DOCUMENTO,VERSION,MONTO_TRANSFERIDO, TIPO_ASIGNACION_RECURSO, TIPO_PROYECTO_DES " + _
                                  " ,COORDX, COORDY, OBSERVACION " + _
                                  "  From POA  " + _
                                  " where poa='" + poa + "'"
            Else
                lxc_SQL = " SELECT NOMBRE,UBIGEO,OBJETIVO,SNIP,TIPO_PROYECTO_ACTIVIDAD,FECHA_VIABILIDAD,CONVENIO " + _
                                  ",PRODUCTO,ESTADO ,PPER,AMBITO,EJECUTOR,MONTO_TOTAL_INVERTIDO,MONTO_INV_ANHIO,PERSONA_MONITOREO " + _
                                  " ,PERSONA_ESPECIALISTA,ANHIO_FIRMA_POA,MES_FIRMA_POA,TIPO_CAMBIO_POA,META,UNIDAD,META2,UNIDAD2 " + _
                                  " ,META3,UNIDAD3,DOCUMENTO,VERSION,MONTO_TRANSFERIDO, TIPO_ASIGNACION_RECURSO, TIPO_PROYECTO_DES " + _
                                  " ,COORDX, COORDY, OBSERVACION " + _
                                  "  From POA_HISTORICO  " + _
                                  " where poa='" + poa + "' AND VERSION ='" + VERH + "'"
            End If

            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt
        Catch ex As Exception
            Throw ex
        End Try
    End Function
    Public Function ListaPOA() As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = "SELECT ROWNUM AS NUMERO, P.NOMBRE, P.MONTO_TOTAL_INVERTIDO, P.MONTO_INV_ANHIO,PM.NOMBRES || ' ' || PM.APELLIDO_PATERNO || ' ' || PM.APELLIDO_MATERNO AS MONITOREADOR, PP.PPER, E.EJECUTOR, E.DESCRIPCION AS EJE_DES , " & _
                      "PE.NOMBRES || ' ' || PE.APELLIDO_PATERNO || ' ' || PE.APELLIDO_MATERNO AS ESPECIALISTA, P.OBJETIVO,P.SNIP,P.FECHA_VIABILIDAD, P.POA ,U.NOMBRE AS UBIGEO, TPA.DESCRIPCION,PP. ABREVIATURA FROM POA P " & _
                      "LEFT JOIN TIPO_PROYECTO_ACTIVIDAD TPA ON TPA.TIPO_PROYECTO_ACTIVIDAD = P.TIPO_PROYECTO_ACTIVIDAD INNER JOIN PPER PP ON PP.PPER = P.PPER " & _
                      "LEFT JOIN PERSONA PM ON PM.PERSONA = P.PERSONA_MONITOREO " & _
                      "LEFT JOIN PERSONA PE ON PE.PERSONA = P.PERSONA_ESPECIALISTA " & _
                      "LEFT JOIN UBIGEO  U ON U.UBIGEO = P.UBIGEO " & _
                      "LEFT JOIN EJECUTOR E ON P.EJECUTOR = E.EJECUTOR  "
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt
        Catch ex As Exception
            Throw ex
        End Try
    End Function
    Public Function Listaidcompohistory(ByVal compoH As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = "select ID_POA_COMPONENTE as ID from POA_COMPONENTE_HISTORICO where COMPONENTE ='" + compoH + "'"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt
        Catch ex As Exception
            Throw ex
        End Try
    End Function
    Public Function ListaPOA(ByVal strNombre As String, ByVal strTipo As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String

        Try

            lxc_SQL = "SELECT ROWNUM AS NUMERO, P.NOMBRE, P.MONTO_TOTAL_INVERTIDO, P.MONTO_INV_ANHIO,PM.NOMBRES || ' ' || PM.APELLIDO_PATERNO || ' ' || PM.APELLIDO_MATERNO AS MONITOREADOR, PP.PPER, E.EJECUTOR, E.DESCRIPCION AS EJE_DES , " & _
                      "PE.NOMBRES || ' ' || PE.APELLIDO_PATERNO || ' ' || PE.APELLIDO_MATERNO AS ESPECIALISTA, P.OBJETIVO,P.SNIP,P.FECHA_VIABILIDAD, P.POA ,U.NOMBRE AS UBIGEO, TPA.DESCRIPCION, PP.ABREVIATURA FROM POA P " & _
                      "INNER JOIN TIPO_PROYECTO_ACTIVIDAD TPA ON TPA.TIPO_PROYECTO_ACTIVIDAD = P.TIPO_PROYECTO_ACTIVIDAD INNER JOIN PPER PP ON PP.PPER = P.PPER " & _
                      "LEFT JOIN PERSONA PM ON PM.PERSONA = P.PERSONA_MONITOREO " & _
                      "LEFT JOIN PERSONA PE ON PE.PERSONA = P.PERSONA_ESPECIALISTA " & _
                      "LEFT JOIN UBIGEO  U ON U.UBIGEO = P.UBIGEO LEFT JOIN EJECUTOR E ON P.EJECUTOR = E.EJECUTOR WHERE 1 = 1 "
            If strNombre <> "" Then
                lxc_SQL = lxc_SQL & "AND UPPER(PP.ABREVIATURA||E.DESCRIPCION||P.NOMBRE) like UPPER('%" & strNombre & "%')"
            End If
            If strTipo <> "all" Then
                lxc_SQL = lxc_SQL & "AND P.TIPO_PROYECTO_ACTIVIDAD = '" & strTipo & "'"
            End If
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt

        Catch ex As Exception
            Throw ex
        End Try
    End Function
    Public Function LISTA_COMPONENTE(ByVal poac As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String

        Try

            lxc_SQL = " select componente, descripcion , version, sub_descripcion from poa_actividad_componente" + _
                      " where poa ='" + poac + "'" + _
                      "order by  descripcion "


            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt

        Catch ex As Exception
            Throw
        End Try
    End Function
    Public Function LISTA_COMPONENTE(ByVal poac As String, ByVal VERS As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String

        Try

            lxc_SQL = "select ROWNUM || ' - ' || DESCRIPCION as descripcion2, componente, descripcion , version, sub_descripcion from poa_componente_historico " + _
                      " where poa ='" + poac + "' AND VERSION =" + VERS + "  order by  descripcion "

            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt

        Catch ex As Exception
            Throw
        End Try
    End Function
    Public Function lista_GENERICA() As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String

        Try

            lxc_SQL = " SELECT GENERICA_GASTOS, GENERICA_GASTOS ||'  '|| DESCRIPCION  as DESCRIPCION FROM GENERICA_GASTOS ORDER BY GENERICA_GASTOS"

            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt

        Catch ex As Exception
            Throw
        End Try
    End Function
    Public Function lista_ESPECIFICA(ByVal generica As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String

        Try

            lxc_SQL = " SELECT ESPECIFICA_GASTO,  DESCRIPCION AS DESCRIPCION, (ESPECIFICA_GASTO || '-' || DESCRIPCION) AS DESCRIPCION2 FROM ESPECIFICA_GASTO " + _
                      " WHERE GENERICA_GASTO='" + generica + "' ORDER BY ESPECIFICA_GASTO "
           
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt

        Catch ex As Exception
            Throw
        End Try
    End Function
    Public Function CargarGrillaComponente(ByVal poa As String, ByVal verch As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String

        Try
            If verch = "" Then
                lxc_SQL = "SELECT ROWNUM || ' - ' || DESCRIPCION AS DESCRIPCION2 ,POA,COMPONENTE as codigo,DESCRIPCION as componente,SUB_DESCRIPCION,VERSION,PESO_COMPONENTE FROM POA_ACTIVIDAD_COMPONENTE " + _
                         " where poa='" + poa + "' ORDER BY TO_NUMBER(CODIGO)"
                objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Else
                lxc_SQL = "SELECT ROWNUM || ' - ' || DESCRIPCION AS DESCRIPCION2 ,POA,COMPONENTE as codigo,DESCRIPCION as componente,SUB_DESCRIPCION,VERSION,PESO_COMPONENTE FROM POA_COMPONENTE_HISTORICO " + _
                                        " where poa='" + poa + "' and version ='" + verch + "' ORDER BY TO_NUMBER(CODIGO)"
                objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            End If

            Return objDt
        Catch ex As Exception
            Throw ex
        End Try
    End Function
    Public Function CargarGrillafisico(ByVal poa As String, ByVal verch As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try

            If verch = "" Then
                lxc_SQL = " SELECT P.SNIP,P.TIPO_PROYECTO_ACTIVIDAD   , PAF.POA  ,  NVL(PAF.META_01, 0) META_01  ,NVL(PAF.META_02, 0) META_02 ,NVL(PAF.META_03, 0) META_03 ,NVL(PAF.META_04, 0) META_04 ,NVL(PAF.META_05, 0) META_05 ,NVL(PAF.META_06, 0) META_06 ,NVL(PAF.META_07, 0) META_07, " + _
           " NVL(PAF.META_08, 0) META_08 , NVL(PAF.META_09, 0) META_09, NVL(PAF.META_10, 0)  META_10 , NVL(PAF.META_11, 0) META_11 , NVL(PAF.META_12, 0) META_12 , NVL(PAF.META_ANUAL, 0) META_ANUAL ,PAF.UNIDAD,U.DESCRIPCION AS UNIDADES , PAF.TAREA_ACTIVIDAD, " + _
           " PAF.TAREA_ACTIVIDAD_DESCRIPCION as tarea ,PAF.ID_POA_ACTIVIDAD_FISICA,PAF.COMPONENTE,PAF.VERSION,PAC.DESCRIPCION AS COMPONENTEDES,PAF.PESO, PAF.CODIGO " + _
           " FROM POA_ACTIVIDAD_FISICA   PAF " + _
           " LEFT JOIN  UNIDAD U ON U.UNIDAD = PAF.UNIDAD " + _
           " LEFT JOIN POA_ACTIVIDAD_COMPONENTE PAC ON PAC.COMPONENTE = PAF.COMPONENTE   " + _
           " LEFT JOIN POA P ON P.POA = PAF.POA " + _
           " where  PAF.poa='" + poa + "' ORDER BY PAF.CODIGO "
                objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Else
                lxc_SQL = "SELECT distinct P.SNIP,P.TIPO_PROYECTO_ACTIVIDAD   , PAF.POA  ,  NVL(PAF.META_01, 0) META_01  ,NVL(PAF.META_02, 0) META_02 ,NVL(PAF.META_03, 0) META_03 ,NVL(PAF.META_04, 0) META_04 ,NVL(PAF.META_05, 0) META_05 ,NVL(PAF.META_06, 0) META_06 ,NVL(PAF.META_07, 0) META_07, " + _
          " NVL(PAF.META_08, 0) META_08 , NVL(PAF.META_09, 0) META_09, NVL(PAF.META_10, 0)  META_10 , NVL(PAF.META_11, 0) META_11 , NVL(PAF.META_12, 0) META_12 , NVL(PAF.META_ANUAL, 0) META_ANUAL ,PAF.UNIDAD,U.DESCRIPCION AS UNIDADDES , PAF.TAREA_ACTIVIDAD, " + _
         " PAF.TAREA_ACTIVIDAD_DESCRIPCION as tarea ,PAF.ID_POA_ACTIVIDAD_FISICA,PAF.COMPONENTE,PAF.VERSION, " + _
         " PAC.DESCRIPCION AS COMPONENTEDES,PAF.PESO, PAF.CODIGO from POA_FISICA_HISTORICO  PAF " + _
          " LEFT JOIN  UNIDAD U ON U.UNIDAD = PAF.UNIDAD " + _
          " LEFT JOIN POA_COMPONENTE_HISTORICO PAC ON PAC.COMPONENTE = PAF.COMPONENTE  " + _
            " LEFT JOIN POA P ON P.POA = PAF.POA  " + _
                 " where  PAF.poa='" + poa + "' and PAF.version =" + verch + " AND PAC.VERSION=" + verch + " "
                objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
                Dim ndt As Integer = objDt.Rows.Count
            End If

            Return objDt
        Catch ex As Exception
            Throw ex
        End Try
    End Function
    Public Function CargarGrillafinanciero(ByVal poa As String, ByVal verch As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try

            If verch = "" Then
                lxc_SQL = "SELECT PAFN.POA ,PAFN.version,GG.GENERICA_GASTOS AS GENERICA_GASTO, EG.ESPECIFICA_GASTO, GG.GENERICA_GASTOS||' '||GG.DESCRIPCION AS GENERICA_GASTODES, EG.DESCRIPCION AS ESPECIFICA_GASTODES ,PAFN.ID_POA_ACTIVIDAD_FINANCIERA,PAFN.POA  , NVL(PAFN.META_01, 0) META_01 ,NVL(PAFN.META_02, 0) META_02 ,NVL(PAFN.META_03, 0) META_03 ,NVL(PAFN.META_04, 0) META_04,NVL(PAFN.META_05, 0) META_05 ,NVL(PAFN.META_06, 0) META_06 ,NVL(PAFN.META_07, 0) META_07 , " + _
" NVL(PAFN.META_08, 0) META_08 , NVL(PAFN.META_09, 0) META_09 , NVL(PAFN.META_10, 0) META_10 , NVL(PAFN.META_11, 0) META_11 , NVL(PAFN.META_12, 0) META_12 , NVL(PAFN.META_ANUAL,0)  META_ANUAL " + _
      " FROM POA_ACTIVIDAD_FINANCIERA   PAFN " + _
       " LEFT JOIN GENERICA_GASTOS GG ON PAFN.GENERICA_GASTO = GG.GENERICA_GASTOS " + _
       " LEFT JOIN ESPECIFICA_GASTO EG ON PAFN.ESPECIFICA_GASTO =  EG.ESPECIFICA_GASTO " + _
       " WHERE PAFN.POA='" + poa + "'  ORDER BY EG.ESPECIFICA_GASTO"
                objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Else
                lxc_SQL = "SELECT PAFN.POA ,PAFN.version,GG.GENERICA_GASTOS AS GENERICA_GASTO, EG.ESPECIFICA_GASTO, GG.GENERICA_GASTOS||' '||GG.DESCRIPCION AS GENERICA_GASTODES, EG.DESCRIPCION AS ESPECIFICA_GASTODES ,PAFN.ID_POA_ACTIVIDAD_FINANCIERA,PAFN.POA  , NVL(PAFN.META_01, 0) META_01 ,NVL(PAFN.META_02, 0) META_02 ,NVL(PAFN.META_03, 0) META_03 ,NVL(PAFN.META_04, 0) META_04,NVL(PAFN.META_05, 0) META_05 ,NVL(PAFN.META_06, 0) META_06 ,NVL(PAFN.META_07, 0) META_07 , " + _
   " NVL(PAFN.META_08, 0) META_08 , NVL(PAFN.META_09, 0) META_09 , NVL(PAFN.META_10, 0) META_10 , NVL(PAFN.META_11, 0) META_11 , NVL(PAFN.META_12, 0) META_12 , NVL(PAFN.META_ANUAL,0)  META_ANUAL " + _
           " FROM poa_financiera_historico   PAFN " + _
            " LEFT JOIN GENERICA_GASTOS GG ON PAFN.GENERICA_GASTO = GG.GENERICA_GASTOS " + _
            " LEFT JOIN ESPECIFICA_GASTO EG ON PAFN.ESPECIFICA_GASTO =  EG.ESPECIFICA_GASTO " + _
            " WHERE PAFN.POA='" + poa + "' and PAFN.version =" + verch + "  ORDER BY EG.ESPECIFICA_GASTO"
                objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
                Dim ndt As Integer = objDt.Rows.Count
            End If



            Return objDt
        Catch ex As Exception
            Throw ex
        End Try
    End Function
    Public Function consult_existencia(ByVal comp As String, ByVal POA As String, ByVal VERSION As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = "select * from poa_actividad_fisica where componente='" + comp + "' AND POA = '" + POA + "' AND VERSION = '" + VERSION + "'"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt
        Catch ex As Exception
            Throw ex
        End Try
    End Function
    Public Function consult_existencia_fisico(ByVal idfis As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = "select *  from poa_fisico_persona where id_poa_actividad_fisica='" + idfis + "'"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt
        Catch ex As Exception
            Throw ex
        End Try
    End Function
    Public Function consult_existencia_financiera(ByVal idfin As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = "select *  from poa_financiero_persona where id_poa_actividad_financiera='" + idfin + "'"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt
        Catch ex As Exception
            Throw ex
        End Try
    End Function
    Public Function consult_version(ByVal POA As String) As Integer
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim vers As Integer
        Dim verc As String
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = "select  version  from poa  where poa ='" + POA + "'"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            verc = objDt.Rows(0).Item("version").ToString
            vers = Convert.ToInt32(verc)
            Return vers
        Catch ex As Exception
            Throw ex
        End Try
    End Function
    Public Function consult_version_FIS(ByVal POA As String) As Integer
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim vers As Integer
        Dim verc As String
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = "SELECT  VERSION from POA_ACTIVIDAD_FISICA  WHERE POA='" + POA + "'"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            verc = objDt.Rows(0).Item("version").ToString
            vers = Convert.ToInt32(verc)
            Return vers
        Catch ex As Exception
            Throw ex
        End Try
    End Function
    Public Function consult_version_FIN(ByVal POA As String) As Integer
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim vers As Integer
        Dim verc As String
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = "SELECT  VERSION from POA_ACTIVIDAD_FINANCIERA WHERE POA='" + POA + "'"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            verc = objDt.Rows(0).Item("version").ToString
            vers = Convert.ToInt32(verc)
            Return vers
        Catch ex As Exception
            Throw ex
        End Try
    End Function
    Public Function consult_version_comp(ByVal POA As String) As Integer
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim versc As Integer
        Dim vers As Integer
        Dim verc As String
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Dim versb As Integer
        Dim vercb As String
        Dim objDtb As DataTable
        Dim lxc_SQLb As String
        Try
            lxc_SQL = " select version  from poa_actividad_componente where  poa ='" + POA + "'"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            verc = objDt.Rows(0).Item("version").ToString
            vers = Convert.ToInt32(verc)
            lxc_SQLb = " select version  from poa_componente_historico where  poa ='" + POA + "' order by  version desc"
            objDtb = objData.ExecuteSQL(lxc_SQLb, "Conexion.Oracle")
            vercb = objDt.Rows(0).Item("version").ToString
            vers = Convert.ToInt32(verc)
            versb = Convert.ToInt32(vercb)
            If vers = versb Then
                versc = vers
            ElseIf versb > vers Then
                versc = versb - 1
            End If
            Return versc
        Catch ex As Exception
            Throw ex
        End Try
    End Function

    Public Function consult_exist_comp(ByVal comp As String) As String
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim verc As String = ""
        Dim objDt As DataTable
        Dim lxc_SQL As String

        Try
            lxc_SQL = " select * from poa_actividad_componente where  componente ='" + comp + "'"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            If objDt.Rows.Count = 0 Then
                verc = ""
            Else
                Dim objDt2 As DataTable
                Dim lxc_SQL2 As String
                lxc_SQL2 = " select version from poa_actividad_componente where componente ='" + comp + "'"
                objDt2 = objData.ExecuteSQL(lxc_SQL2, "Conexion.Oracle")
                Dim objDt3 As DataTable
                Dim lxc_SQL3 As String
                lxc_SQL3 = " select version from poa_componente_historico where componente ='" + comp + "' order by version desc "
                objDt3 = objData.ExecuteSQL(lxc_SQL3, "Conexion.Oracle")
                Dim cp As Integer = Convert.ToUInt32(objDt2.Rows(0).Item("Version"))
                Dim ch As Integer = Convert.ToUInt32(objDt3.Rows(0).Item("Version"))
                'B => Borrador
                'PB =>Post Borrador
                If cp < ch Then
                    verc = "B"
                ElseIf cp = ch Then
                    verc = "PB"
                End If

            End If

            Return verc
        Catch ex As Exception
            Throw ex
        End Try
    End Function

    Public Function consult_exist_fis(ByVal idfis As String) As String
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim verfis As String = ""
        Dim objDt As DataTable
        Dim lxc_SQL As String

        Try
            lxc_SQL = " SELECT VERSION FROM POA_ACTIVIDAD_FISICA  where  ID_POA_ACTIVIDAD_FISICA ='" + idfis + "'"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            If objDt.Rows.Count = 0 Then
                verfis = "3"
            Else                
                Dim objDt3 As DataTable
                Dim lxc_SQL3 As String
                lxc_SQL3 = " SELECT VERSION FROM POA_FISICA_HISTORICO  where ID_POA_ACTIVIDAD_FISICA ='" + idfis + "' order by version desc "
                objDt3 = objData.ExecuteSQL(lxc_SQL3, "Conexion.Oracle")
                Dim cp As Integer = Convert.ToUInt32(objDt.Rows(0).Item("Version"))
                Dim ch As Integer = Convert.ToUInt32(objDt3.Rows(0).Item("Version"))
                If cp < ch Then
                    verfis = "2"
                ElseIf cp = ch Then
                    verfis = "1"
                End If
            End If
            Return verfis
        Catch ex As Exception
            Throw ex
        End Try
    End Function

    Public Function consult_exist_fin(ByVal idfin As String) As String
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim verfin As String = ""
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = " SELECT VERSION FROM POA_ACTIVIDAD_FINANCIERA  where  ID_POA_ACTIVIDAD_FINANCIERA ='" + idfin + "'"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            If objDt.Rows.Count = 0 Then
                verfin = "3"
            Else

                Dim objDt3 As DataTable
                Dim lxc_SQL3 As String
                lxc_SQL3 = " SELECT VERSION FROM POA_FINANCIERA_HISTORICO  where ID_POA_ACTIVIDAD_FINANCIERA ='" + idfin + "' order by version desc "
                objDt3 = objData.ExecuteSQL(lxc_SQL3, "Conexion.Oracle")
                Dim cp As Integer = Convert.ToUInt32(objDt.Rows(0).Item("Version"))
                Dim ch As Integer = Convert.ToUInt32(objDt3.Rows(0).Item("Version"))
                If cp < ch Then
                    verfin = "2"
                ElseIf cp = ch Then
                    verfin = "1"
                End If

            End If
            Return verfin
        Catch ex As Exception
            Throw ex
        End Try
    End Function

    Public Function VER_BORRADOR(ByVal POA As String) As String
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim objDt2 As DataTable
        Dim lxc_SQL1 As String
        Dim lxc_SQL2 As String
        Dim Borrador As String
        Try
            lxc_SQL1 = "select version from poa where poa = '" + POA + "' AND ROWNUM <2" + _
                          "ORDER BY VERSION DESC"
            objDt = objData.ExecuteSQL(lxc_SQL1, "Conexion.Oracle")
            Dim r1 As Integer = Convert.ToUInt32(objDt.Rows(0).Item("Version"))
            lxc_SQL2 = "SELECT VERSION FROM POA_HISTORICO  where poa = '" + POA + "' AND ROWNUM <2" + _
                          "ORDER BY VERSION DESC"
            objDt2 = objData.ExecuteSQL(lxc_SQL2, "Conexion.Oracle")
            Dim r2 As Integer = Convert.ToUInt32(objDt2.Rows(0).Item("Version"))
            If r2 > r1 Then
                Borrador = Convert.ToString(r2)
            Else
                Borrador = ""
            End If
            Return Borrador
        Catch ex As Exception
            Throw ex
        End Try
    End Function

    Public Function Consulta_Existencia_Hijos_Metas_Fisicas(ByVal POA As String, ByVal VERSION As String, ByVal ID_FIS As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = "SELECT VERIFICA_EJEC_ITEM_FISICO('" + POA + "'," + VERSION + ",'" + ID_FIS + "') EXISTE FROM DUAL"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt
        Catch ex As Exception
            Throw ex
        End Try
    End Function
    Public Function Consulta_Existencia_Hijos_Metas_Financieras(ByVal POA As String, ByVal VERSION As String, ByVal ID_FIN As String) As DataTable
        Dim objData As AdministradorOracle = New AdministradorOracle
        Dim objDt As DataTable
        Dim lxc_SQL As String
        Try
            lxc_SQL = "SELECT VERIFICA_EJEC_ITEM_FINANCIERO('" + POA + "'," + VERSION + ",'" + ID_FIN + "') EXISTE FROM DUAL"
            objDt = objData.ExecuteSQL(lxc_SQL, "Conexion.Oracle")
            Return objDt
        Catch ex As Exception
            Throw ex
        End Try
    End Function
End Class
